//
//  FJFriendsListViewController.swift
//  FruitJuice
//
//  Created by Rui on 2023/12/16.
//

import UIKit

class FJFriendsListViewController: FJBaseViewController {

    private let backButton          = c_make_ex(UIButton.self)
        .image("FJ_Profile_back").end()
    private let followBtn           = c_make_ex(UIButton.self)
        .text("Following").color(.black,state: .selected)
        .color("#B5B5B5").font(19.font_bold).end()
    private let followedBtn         = c_make_ex(UIButton.self)
        .text("Followed").color(.black,state: .selected)
        .color("#B5B5B5").font(19.font_bold).end()
//    private lazy var tableView: UITableView = {
//        let tableView = UITableView()
//        tableView.backgroundColor = .clear
//        tableView.tableFooterView = UIView(frame: .zero)
//        tableView.separatorStyle = .none
//        tableView.delegate = self
//        tableView.dataSource = self
//        tableView.rowHeight = 85
//        tableView.register(FJBlackTableViewCell.self)
//
//        return tableView
//    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        navigation.bar.isHidden = true
        view.subviews{
            backButton
            followBtn
            followedBtn
//            tableView
        }
        
        backButton.top(.statusHeight + 7).leading(15).size(30)
        followBtn.leading(52.5).width(98).height(30)
        followBtn.CenterY == backButton.CenterY
        followedBtn.width(98).height(30)
        followedBtn.Leading == followBtn.Trailing
        followedBtn.CenterY == backButton.CenterY
//        tableView.leading(0).trailing(0).bottom(.safe_bottom)
//        tableView.Top == backButton.Bottom + 7
        
        followBtn.isSelected = true
        backButton.addTarget(self, action: #selector(clickBackButton), for: .touchUpInside)
        followBtn.addTarget(self, action: #selector(clickFollowingButton), for: .touchUpInside)
        followedBtn.addTarget(self, action: #selector(clickFollowedButton), for: .touchUpInside)
    }

    @objc private func clickBackButton(){
        self.navigationController?.popViewController(animated: true)
    }
    @objc private func clickFollowingButton(){
        
        if !followBtn.isSelected {
            followBtn.isSelected = true
            followedBtn.isSelected = false
        }
    }
    @objc private func clickFollowedButton(){
        
        if !followedBtn.isSelected {
            followedBtn.isSelected = true
            followBtn.isSelected = false
        }
    }
}

//extension FJFriendsListViewController: UITableViewDelegate,UITableViewDataSource{
//    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
////        itemInfos.count
//        return 10
//    }
//
//    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
//        let cell = tableView.cell(FJBlackTableViewCell.self, indexPath: indexPath)
////        cell.itemType = itemInfos[indexPath.row]
//        return cell
//    }
//    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
//
//        tableView.deselectRow(at: indexPath, animated: true)
//
//    }
//}

class FJFriendsTableViewCell: UITableViewCell {
    
    private let backView            = c_make_ex(UIView.self)
        .bgColor("#EFEFEF").corner(35).end()
    private let iconImageView       = c_make_ex(UIImageView.self)
        .mode(.scaleAspectFill).corner(25).end()
    private let nameLabel           = c_make_ex(UILabel.self)
        .color(.black).font(16.font_bold).end()
    private let contentLabel        = c_make_ex(UILabel.self)
        .color(.black).font(14.font_regular).end()
    private let removeButton        = c_make_ex(UIButton.self)
        .bgColor("#FC9C05").corner(20).color(.white).font(17.font_bold).end()
    
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none
        backgroundColor = .clear
        contentView.backgroundColor = .clear
        
        contentView.subviews {
            backView.subviews{
                iconImageView
                nameLabel
                contentLabel
                removeButton
            }
        }
        backView.leading(15).trailing(15).top(15).bottom(0)
        iconImageView.leading(10).size(50).centerVertically()
        nameLabel.leading(70).trailing(120).top(15)
        contentLabel.trailing(120).leading(70)
        contentLabel.Top == nameLabel.Bottom + 3
        removeButton.width(100).trailing(10).height(40).centerVertically()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
